#!/usr/bin/env bash

sudo apt-get install -y git g++ make libmbedtls-dev libssl-dev liblz4-dev python3-dev liblzo2-dev libasio-dev python3 swig openjdk-8-jre-headless

if [ -e "/usr/bin/python" ]; then
    echo "python already exists."
else
    sudo ln -s /usr/bin/python3.10 /usr/bin/python
fi

export O3=~/ovpn3
export DEP_DIR=$O3/deps
export DL=$O3/dl

sudo rm -rf $O3
mkdir $O3
mkdir $DEP_DIR
mkdir $DL

cd $O3
git clone https://gitee.com/zhouh666/ovpn3.git core

#build for android
ECHO=1 $O3/core/scripts/android/build-all

#build for linux
cd $O3/core/test/ovpncli
ECHO=1 PROF=linux ASIO_DIR=~/asio MTLS_SYS=1 LZ4_SYS=1 NOSSL=1 $O3/core/scripts/build cli
cp ~/client.ovpn myprofile.ovpn
./cli -a -c yes myprofile.ovpn route-nopull